#include "YuzhiLineEdit.h"
#include "resultcurvechart.h"

YuzhiLineEdit::YuzhiLineEdit (QWidget *parent) : QLineEdit (parent) {
    setReadOnly (true); // 初始设置为只读

    /* 数字验证器 */
//    QRegExp rx ("^[0-9]*$");
    QDoubleValidator *validator = new QDoubleValidator (0, 999999999999999999999999999.99, 2, this);
    this->setValidator (validator);

}

void YuzhiLineEdit::mouseDoubleClickEvent (QMouseEvent *event) {
    QLineEdit::mouseDoubleClickEvent (event); // 调用父类的方法
//    emit doubleClicked (true); // 发射自定义信号

    setReadOnly(false);
//    setText("123");
}

void YuzhiLineEdit::focusOutEvent(QFocusEvent *event) {
    QString text = this->text();
    double value = text.toDouble();

    emit YuzhiLineEdit::returnYuzhi(this->yuzhiID,value);
//    emit ResultCurveChart::updateYuZhi(this->result->resultChart->yuZhiHash);
    LOG << this->result->resultChart->yuZhiHash;

//    result->resultChart->updateYuZhiLabelPos(this, value);
//    this->result->resultChart->updateYuZhi(this->result->resultChart->yuZhiHash);
    setReadOnly (true); // 编辑完成后设置为只读
    LOG << "失焦事件更新";
}

// 获取结果页面图表
void YuzhiLineEdit::getResultrchart(ExperimentResultUi *result){
    this->result=result;
}
